package it.poste.il.compensatore.service.impl;

import it.poste.il.compensatore.dao.MessageStatusDao;
import it.poste.il.compensatore.entities.MessageStatus;
import it.poste.il.compensatore.service.MessageStatusService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Implementation of MessageStatusService.
 */
@Service("messageStatusService")
public class MessageStatusServiceImpl implements MessageStatusService {

	@Autowired(required=true) 
	static MessageStatusDao messageStatusDao;

	
	private static MessageStatusServiceImpl messageStatusServiceImpl;
	
	private MessageStatusServiceImpl()
	{}
	public static MessageStatusServiceImpl getInstance()
	{
		if(messageStatusServiceImpl==null)
			messageStatusServiceImpl=new MessageStatusServiceImpl();
		return messageStatusServiceImpl;
	}
	
	
	/**
	 * Take the message status dao.
	 * @return MessageStatusDao The message status dao.
	 */
	public MessageStatusDao getMessageStatusDao() {
		return messageStatusDao;
	}

	/**
	 * Set the message status dao.
	 * @param messageStatusDao The message status dao to set.
	 * @return void
	 */
	public void setMessageStatusDao(MessageStatusDao messageStatusDao) {
		this.messageStatusDao = messageStatusDao;
	}

	/**
	 * Method that retrieve the message status by string id.
	 * @param id Id to identify the message status.
	 * @return MessageStatus The entity MessageStatus.
	 */
	public MessageStatus retrieveByID(String id) {
		return messageStatusDao.findById(id);
	}

	/**
	 * Method that retrieve the message status by long id.
	 * @param id Id to identify the message status.
	 * @return MessageStatus The entity MessageStatus.
	 */
	public MessageStatus loadByID(Long id) {
		return messageStatusDao.loadById(id);
	}

	/**
	 * Method that retrieve the string status by long id.
	 * @param msgSts The Message Status.
	 * @return String The description of the entity Message Status.
	 */
	public String retrieveDescription(MessageStatus msgSts) {
		return messageStatusDao.selectDescription(msgSts);
	}

	/**
	 * The list of all message status.
	 * @return List The list of Message Status.
	 */
	public List<MessageStatus> retrieveAll() {
		return messageStatusDao.loadAll();
	}

	/**
	 * Method that save the message status.
	 * @param messageStatus Message status to save.
	 * @return MessageStatus The Message Status saved.
	 */
	public MessageStatus save(MessageStatus messageStatus) {
		return messageStatusDao.save(messageStatus);
	}

	/**
	 * Update the message status.
	 * @param message Message Status to update.
	 * @return void
	 */
	public void update(MessageStatus messageStatus) {
		messageStatusDao.update(messageStatus);
	}

	/**
	 * Delete the message status.
	 * @param messageStatus Message Status to delete.
	 * @return void
	 */
	public void delete(MessageStatus messageStatus) {
		messageStatusDao.delete(messageStatus);
	}
	
}
